# -*- coding: utf-8 -*-
"""
Module Description: 创建唯一键相关
Date: 2016/11/1
Author:Bai Jin Ping
"""
import uuid


def create_idx(use_v6=False):
    """
    创建并返回唯一键(len=32的字符串)

    :param use_v6: 返回重排过的uuid值(默认值不能改为True,可能会跟之前的uuidv1.hex数据出现重复)
    :return:
    """
    uuidv1 = uuid.uuid1().hex
    if use_v6:
        return _uuidv1_to_v6(uuidv1)
    return uuidv1


def _uuidv1_to_v6(uuidv1):
    return uuidv1[12:16] + uuidv1[8:12] + uuidv1[0:8] + uuidv1[16:]


if __name__ == '__main__':
    print create_idx()
    print create_idx(use_v6=True)